<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Message extends Model
{
    /**
     * 表名
     * @var string
     */
    protected $table = 'messages';

    /**
     * 主键
     * @var string
     */
    protected $primaryKey = 'id';

    /**
     * 可填充的字段
     * @var array
     */
    protected $fillable = [
        "u_id", "title", "content", "ip",
    ];

    /**
     * 新增修改时间
     * @var bool
     */
    public $timestamps = true;

    /**
     * 获取留言关联到的用户
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function user()
    {
        return $this->hasOne(User::class, 'id', 'u_id');
    }

}
